﻿<%-- 
This file is part of Ingo Karstein's SharePoint PowerShell Timer Jobs project

**Do not remove this comment**

Please see the project homepage at CodePlex:
  http://sppowershelltimerjob.codeplex.com/

Please see my blog:
  http://ikarstein.wordpress.com

Licence: GPLv2
    Ingo Karstein's SharePoint PowerShell Timer Jobs
    Copyright (C) 2011  Ingo Karstein, ikarstein@hotmail.com

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--%>
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
    Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ManageJobs.aspx.cs" Inherits="ik.SharePoint2010.SPPowerShellTimerJob.Layouts.SPPowerShellTimerJob.ManageJobs"
    DynamicMasterPageFile="~masterurl/default.master" %>

<%@ Register TagPrefix="wssuc" TagName="InputFormSection" Src="~/_controltemplates/InputFormSection.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="InputFormControl" Src="~/_controltemplates/InputFormControl.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ButtonSection" Src="~/_controltemplates/ButtonSection.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="SchedulePicker" Src="~/_controltemplates/SchedulePicker.ascx" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
    Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="wssawc" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
    Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="AdminControls" Namespace="Microsoft.SharePoint.WebControls"
    Assembly="Microsoft.SharePoint.ApplicationPages.Administration" %>
<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
    <script language="javascript" type="text/javascript">
<% if(CurrentJob != null ) { %>
    function ikShowEditScriptDlgRefresh(dialogResult, returnValue) {
       __doPostBack('<%= refresh.ClientID %>','');
    }
    function ikShowEditScriptDlg() {
        var pageurl = '/_admin/ikSPPowerShellTimerJobs/EditScript.aspx';

        var options = {
            url: pageurl + '?jobdefid=<%=CurrentJob.Id.ToString()%>',
            tite: 'Edit PowerShell Script of Timer Job',
            allowMaximize: true,
            showClose: true,
            width: 800,
            height: 400,
            dialogReturnValueCallback: ikShowEditScriptDlgRefresh
        };
        SP.UI.ModalDialog.showModalDialog(options);
    }  
    <%} %>
    </script>
</asp:Content>
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    <table width="100%" class="propertysheet" cellspacing="0" cellpadding="0" border="0">
        <tr>
            <td class="ms-descriptionText">
                <asp:Label ID="LabelMessage" runat="server" EnableViewState="False" class="ms-descriptionText" />
            </td>
        </tr>
        <tr>
            <td class="ms-error">
                <asp:Label ID="LabelErrorMessage" runat="server" EnableViewState="False" />
            </td>
        </tr>
        <tr>
            <td class="ms-descriptionText">
                <asp:ValidationSummary ID="ValSummary" HeaderText="VaidationSummary" DisplayMode="BulletList"
                    ShowSummary="True" runat="server"></asp:ValidationSummary>
            </td>
        </tr>
    </table>
 
    <asp:UpdatePanel>
        <table border="0" cellspacing="0" cellpadding="0" width="100%">
            <wssuc:inputformsection title="Ingo Karstein's SharePoint PowerShell Timer Jobs"
                runat="server">
            </wssuc:inputformsection>
            <wssuc:inputformsection title="Modify or Create PowerShell Timer Job" runat="server">
                <template_description>
            <SharePoint:EncodedLiteral runat="server" text="Choose PowerShell Job or select &quot;&lt;new&gt;&quot; to select a new one.
            
To create a new PowerShell Timer you just select &quot;&lt;new&gt;&quot; in the Drop Down, enter a name, select the scheduling and click &quot;Add&quot;." EncodeMethod='HtmlEncodeAllowSimpleTextFormatting'/>
         </template_description>
                <template_inputformcontrols>
            <wssuc:InputFormControl LabelText="Choose Timer Job" LabelAssociatedControlID="dpdTimerjobs" runat="server">
                <Template_control>
                    <asp:DropDownList ID="dpdTimerjobs" runat="server"></asp:DropDownList>
                </Template_control>
            </wssuc:InputFormControl>
            </template_inputformcontrols>
            </wssuc:inputformsection>
            <wssuc:inputformsection title="PowerShell Timer Job settings" runat="server">
                <template_description>
            <SharePoint:EncodedLiteral ID="EncodedLiteral1" runat="server" text="Here you can activate or deactivate your PowerShell Timer Jobs. Deactivated job will not be executed even if they are existing and ediable here.

At next you have to select the server where the timer job should be executed. You can select a special server or a special server.

Now enter a name for your PowerShell Timer Job.

At least select a scheduling for your PowerShell Timer Job.

To finish press &quot;Add&quot; or &quot;Update&quot; Press &quot;Cancel&quot; to discard your changes. Press &quot;Delete&quot; to delete the selected timer job." EncodeMethod='HtmlEncodeAllowSimpleTextFormatting'/>
         </template_description>
                <template_inputformcontrols>
            <wssuc:InputFormControl LabelText="Job state" LabelAssociatedControlID="cbActived" runat="server">
                <Template_control>
                    <asp:CheckBox ID="cbActived" text="Job activated" runat="server"/>
                </Template_control>
            </wssuc:InputFormControl>
            <wssuc:InputFormControl LabelText="Execution method" LabelAssociatedControlID="cbRunAsJob" runat="server">
                <Template_control>
                    <asp:CheckBox ID="cbRunAsJob" text="Run only on one machine" runat="server"/>
                </Template_control>
            </wssuc:InputFormControl>
            <wssuc:InputFormControl LabelText="Choose Type" LabelAssociatedControlID="rType" runat="server" id="FormType">
                <Template_control>
                    <asp:RadioButtonList ID="rType" runat="server"><asp:ListItem Text="Service" value="0" runat="server" /><asp:ListItem Text="Web Application" value="1" runat="server" /></asp:RadioButtonList>
                </Template_control>
            </wssuc:InputFormControl>
            <wssuc:InputFormControl LabelText="Services" LabelAssociatedControlID="dpdServices" runat="server" id="FormServices">
                <Template_control>
                    <asp:DropDownList ID="dpdServices" runat="server"></asp:DropDownList>
                </Template_control>
            </wssuc:InputFormControl>
            <wssuc:InputFormControl LabelText="WebApplication" LabelAssociatedControlID="dpdWebApp" runat="server" id="FormWebApp">
                <Template_control>
                    <asp:DropDownList ID="dpdWebApp" runat="server"></asp:DropDownList>
                </Template_control>
            </wssuc:InputFormControl>
            <wssuc:InputFormControl LabelText="Server" LabelAssociatedControlID="dpdServer" runat="server">
                <Template_control>
                    <asp:DropDownList ID="dpdServer" runat="server"></asp:DropDownList>
                </Template_control>
            </wssuc:InputFormControl>
            <wssuc:InputFormControl LabelText="Name" LabelAssociatedControlID="JobName" runat="server">
               <Template_control>
                   <wssawc:InputFormTextBox title="Job Name" class="ms-input" ID="JobName" Columns="35" Runat="server" MaxLength="255" />
                   <SharePoint:InputFormRegularExpressionValidator
                        ID="RegexValFromAddress"
                        ControlToValidate="JobName"
                        ValidationExpression=".*"
                        ErrorMessage="Timer Job name is invalid."
                        Runat="server" />
                        <SharePoint:InputFormCustomValidator ID="JobNameValidator" runat="server" Display="Dynamic" SetFocusOnError="true"
      ControlToValidate="JobName"
      OnServerValidate="ValidateJobName"
      ErrorMessage="Job Name already in use."
      ValidateEmptyText="false" />
                        <br /><br />
               </Template_control>
            </wssuc:InputFormControl>
            <wssuc:InputFormControl LabelText="Schedule" LabelAssociatedControlID="SchedulePicker" runat="server">
               <Template_control>
                   <wssuc:SchedulePicker 
                        ID="SchedulePicker"
                        Minutes="true"
                        Hourly="true"
                        Daily="true"
                        Weekly="true"
                        Monthly="true"
                                                Runat="server" />
               </Template_control>
            </wssuc:InputFormControl>
            <wssuc:buttonsection runat="server">
        <Template_Buttons>
                    <asp:Button id="btnAddOrUpdate"  runat="server"  class="ms-ButtonHeightWidth"  UseSubmitBehavior="false" Text="Add" />
                    <asp:Button id="btnDelete"  runat="server"  class="ms-ButtonHeightWidth"  UseSubmitBehavior="false" Text="Delete" />
                    </Template_Buttons>
             </wssuc:buttonsection>
            </template_inputformcontrols>
            </wssuc:inputformsection>
            <wssuc:inputformsection title="PowerShell Timer Job script" runat="server">
            <template_description>
            <SharePoint:EncodedLiteral  runat="server" text="In this settings section you can view the PowerShell Timer Job script. To edit the scipt just press &quot;Edit&quot;" EncodeMethod='HtmlEncodeAllowSimpleTextFormatting'/>
         </template_description>
                <template_inputformcontrols>
            <wssuc:InputFormControl LabelText="" LabelAssociatedControlID="txtPowerShellScript" runat="server" >
                <Template_control>
                <asp:Button      ID="btnEdit" runat="server" UseSubmitBehavior="false" Text="Edit Script" /><br /><br />
                    <wssawc:InputFormTextBox title="PowerShell Script" class="ms-input" ID="txtPowerShellScript" Runat="server" ReadOnly="true" Width="90%" textmode="MultiLine" Rows="20"  />
                </Template_control>
            </wssuc:InputFormControl>
         </template_inputformcontrols>
            </wssuc:inputformsection>
            <wssuc:buttonsection runat="server">
                <template_buttons>
        
            <asp:Button UseSubmitBehavior="false" runat="server" class="ms-ButtonHeightWidth" Text="<%$Resources:wss,multipages_okbutton_text%>" id="BtnSubmitGlobalEmailConfig" accesskey="<%$Resources:wss,okbutton_accesskey%>"/><span style="display:none;overflow:hidden;width:1px;height:1px;"><asp:Button  ID="refresh"  UseSubmitBehavior="false" Text="&nbsp;" runat="server" /></span>
        </template_buttons>
            </wssuc:buttonsection>
        </table>
    </asp:UpdatePanel> 

</asp:Content>
<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
    Ingo Karstein's SharePoint PowerShell Timer Jobs - Manage 
</asp:Content>
<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea"
    runat="server">
    Ingo Karstein's SharePoint PowerShell Timer Jobs - Manage 
</asp:Content>
